@echo off
REM Automatically execute all SQL migration scripts in the migrations folder

REM === Please fill in the username, password, and database name as needed ===
set MYSQL_USER=stock_user
set MYSQL_PWD=stock123
set MYSQL_DB=stock_data

REM === Execute all SQL files ===
for %%f in (*.sql) do (
    echo Executing %%f ...
    docker exec -i stock_mysql mysql -u%MYSQL_USER% -p%MYSQL_PWD% %MYSQL_DB% < %%f
    if errorlevel 1 (
        echo Error occurred while executing %%f, batch process aborted!
        exit /b 1
    )
)
echo All migration scripts executed successfully!
pause 